//
//  PersonInformationController.m
//  JF_New_DYKT
//
//  Created by 陈雷 on 2017/8/30.
//  Copyright © 2017年 陈雷. All rights reserved.
//

#import "PersonInformationController.h"
#import "EditPsInformationViewController.h"


@interface PersonInformationController ()<UITableViewDataSource,UITableViewDelegate>

@property (strong, nonatomic) IBOutlet UIView *tbvHeaderV;

@property (strong, nonatomic) IBOutlet UIView *contentV;

@property (weak, nonatomic) IBOutlet UITableView *tbv;


@property (weak, nonatomic) IBOutlet UIView *navgationV;

@property (weak, nonatomic) IBOutlet UIImageView *navImg;

@property (weak, nonatomic) IBOutlet UIImageView *userLogoImv;
@property (weak, nonatomic) IBOutlet UILabel *nickNameL;

@property (weak, nonatomic) IBOutlet UILabel *userIdL;

@property (weak, nonatomic) IBOutlet UILabel *focusLb;

@property (weak, nonatomic) IBOutlet UILabel *fansLb;

@property (weak, nonatomic) IBOutlet UILabel *ocupationLb;

@property (weak, nonatomic) IBOutlet UILabel *areaLb;

@property (weak, nonatomic) IBOutlet UILabel *userSignLb;


@end

@implementation PersonInformationController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tbvHeaderV.frame = CGRectMake(0, 0, KSCreenWidth, 263);
    self.contentV.frame = CGRectMake(0, 0, KSCreenWidth, 624);
    
    self.tbv.tableHeaderView = self.tbvHeaderV;
    self.tbv.tableFooterView = self.contentV;
    self.navgationV.backgroundColor = [UIColor clearColor];
    
    
    if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
    [self getMessage];
}


- (void)getMessage{

    self.nickNameL.text = self.msgModel.NICK_NAME;
    [self.userLogoImv sd_setImageWithURL:[NSURL URLWithString:self.msgModel.LOGO] placeholderImage:[UIImage imageNamed:@"headerImgZhanWei.png"]];
    self.userIdL.text = [NSString stringWithFormat:@"ID:%@",self.msgModel.ID];
    
    self.ocupationLb.text = [NSString stringWithFormat:@"关注：%@",self.msgModel.COLLECTION_COUNT];
    
    self.fansLb.text = [NSString stringWithFormat:@"粉丝：%@",self.msgModel.fans_count];
    
    if (self.msgModel.OCCUPATION.length > 0) {
        self.ocupationLb.text = self.msgModel.OCCUPATION;
    }else{
        self.ocupationLb.text = @"未填写";
    }
    
    
    self.areaLb.text = [self.msgModel.AREA stringByReplacingOccurrencesOfString:@";" withString:@" "];
    
    if (self.msgModel.USER_SIGN.length > 0) {
        self.userSignLb.text = self.msgModel.USER_SIGN;
    }else{
        self.userSignLb.text= @"主人很懒，什么也没留下...";
    }
    
    
    
    
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"默认封面"] forBarMetrics:UIBarMetricsDefault];
//    self.navigationController.navigationBar.translucent = YES;
//    [self.navigationController.navigationBar setBarTintColor:[UIColor clearColor]];
    self.navigationController.navigationBar.hidden = YES;
    [self getAllUserinfo];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = NO;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (UIStatusBarStyle)preferredStatusBarStyle {
    
    return UIStatusBarStyleLightContent;
}


- (IBAction)backAction:(UIButton *)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
    
}


- (IBAction)editAction:(UIButton *)sender {
    
    EditPsInformationViewController *editVc = [[EditPsInformationViewController alloc]init];
    
    editVc.msgModel = self.msgModel;
    
    __weak typeof(self) weakSelf = self;
    editVc.transB = ^(MineMessageModel *model){
    
        weakSelf.msgModel = model;
        [weakSelf getMessage];
    };
    
    [self.navigationController pushViewController:editVc animated:YES];
}


- (IBAction)foucousOrFansAction:(UIButton *)sender {
    
    if (sender.tag == 500) {
    
    }else if (sender.tag == 600){
    
    }
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (scrollView.contentOffset.y > 50) {
        self.navImg.image = [UIImage imageNamed:@"默认封面.png"];
    }else{
        self.navImg.image = [UIImage imageNamed:@""];
    }
    NSLog(@"%lf",scrollView.contentOffset.y);

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    return nil;
}


- (void)getAllUserinfo{
    
    NSString *urlStr = [NSString stringWithFormat:@"%@user/Personal/getUserInfo",kDomainName];
    
    NSDictionary *paraDic = @{@"userId":USERID};
    
    BaseRequest *request =  [BaseRequest sharedBaseRequest];
    [request post:urlStr params:paraDic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if ([responseObject[@"code"] isEqualToString:@"1"] ) {
            
            self.msgModel = [MineMessageModel mj_objectWithKeyValues:responseObject[@"data"]];
            [self getMessage];
        }else{
            [JKToast showWithText:responseObject[@"message"]];
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
}


@end
